package com.wx.chapter17.threaduse;

/**
 * @Author : 佩萁
 * Description :
 * @Create : 2023/8/17 - 11:16
 */
public class Thread02 {
    public static void main(String[] args) {
        Tiger tiger = new Tiger();
        ThreadProxy threadProxy = new ThreadProxy(tiger);
        threadProxy.start();
    }
}

class Animal {
}

class Tiger extends Animal implements Runnable {

    @Override
    public void run() {
        System.out.println("老虎嗷嗷叫....");
    }
}

class ThreadProxy implements Runnable {
    private Runnable target = null;//设置一个Runnable类型的属性

    @Override
    public void run() {
        if (target != null) {
            target.run();//动态绑定
        }
    }

    public ThreadProxy(Runnable target) {
        this.target = target;
    }

    public void start() {
        start0();
    }

    public void start0() {
        run();
    }
}